import {Component} from 'angular2/core';
import {LanmonEvent} from './lanmonevent';
import {LanmonEventService} from './lanmonevent.service';
import {WikipediaService} from './lanmonjsonpser';
import {EVT} from './mock-event';
import {Observable}     from 'rxjs/Observable';
import {JSONP_PROVIDERS}  from 'angular2/http';
import {HTTP_PROVIDERS}    from 'angular2/http';
import {OnInit} from 'angular2/core';

@Component({
    selector: 'my-app',
    template: `<div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    <p>故障描述</p>
                </div>
                <div class="weui_cell_ft"><p id="issuedesc_div">{{evt.desc}}</p></div>
                </div>
                <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    <p>上门日期</p>
                </div>
                <div class="weui_cell_ft">{{evt.plantime}}</div>
                </div>

                <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                <p>预约时间</p>
                </div>
                <div class="weui_cell_ft">{{evt.evttime}}</div>
                </div>
                 <div class="weui_cell">
                    <div class="weui_cell_bd weui_cell_primary">
                        <p>派遣员工</p>
                    </div>
                    <div class="weui_cell_ft">
                        <div class="weui_cell_ft">{{evt.engineername}}
                        </div>
                    </div>
                </div>
                <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    <p>员工照片</p>
                </div>
                <div class="weui_cell_ft"><img src={{evt.engineerid}} width="180px" height="180px"></div>
                </div>
                `,
    providers: [HTTP_PROVIDERS, LanmonEventService, WikipediaService, JSONP_PROVIDERS]

})
export class AppComponent implements OnInit{
    title = "@LANMON";
    evt: LanmonEvent = new LanmonEvent();
    data_prefix = "data";
    constructor(private _lanmonEventService: LanmonEventService){}
    getLmEvtFromServer(){
        this._lanmonEventService.getEvtFromServer(this.data_prefix + window.location.search)
        //this._lanmonEventService.getEvtFromServer2()
            .subscribe(e=>{
                //alert(e.engineerid);
                this.evt = e;
                this.evt.engineerid = "portrait/"+this.evt.engineerid+ ".jpg";
          });
    }
    ngOnInit() {
       //this.evt = this._lanmonEventService.getEvt();
        this.getLmEvtFromServer();
    }
}

